package me.zhengjie.modules.quartz.task.pull;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.quartz.service.dto.SyncCommon;
import me.zhengjie.modules.sync.pull.AreaSync;
import me.zhengjie.modules.sync.pull.DistrictSync;
import me.zhengjie.modules.sync.pull.EstatePhotoSync;
import me.zhengjie.modules.sync.pull.EstateSync;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class PropertyDependentPullTask extends PullTaskBase {
    @Autowired
    private DistrictSync districtSync;
    @Autowired
    private AreaSync areaSync;
    @Autowired
    private EstateSync estateSync;
    @Autowired
    private EstatePhotoSync estatePhotoSync;

    public PropertyDependentPullTask() {
        setTaskName(this.getClass().getSimpleName());
    }

    @Override
    protected void pull(SyncCommon syncCommon, Date date) {
        //区域
        log.info("run companyUuid {} districtSync start ", syncCommon.getCompanyUuid());
        Long startTime = System.currentTimeMillis();
        districtSync.pull(syncCommon, date);
        Long endTime = System.currentTimeMillis();
        log.info("run companyUuid {} districtSync end {} ", syncCommon.getCompanyUuid(), (endTime - startTime));

        //商圈
        log.info("run companyUuid {} areaSync start ", syncCommon.getCompanyUuid());
        startTime = System.currentTimeMillis();
        areaSync.pull(syncCommon, date);
        endTime = System.currentTimeMillis();
        log.info("run companyUuid {} areaSync end {} ", syncCommon.getCompanyUuid(), (endTime - startTime));

        //楼盘
        log.info("run companyUuid {} estateSync start ", syncCommon.getCompanyUuid());
        startTime = System.currentTimeMillis();
        estateSync.pull(syncCommon, date);
        endTime = System.currentTimeMillis();
        log.info("run companyUuid {} estateSync end {} ", syncCommon.getCompanyUuid(), (endTime - startTime));

        //楼盘图片
        log.info("run companyUuid {} estatePhotoSync start ", syncCommon.getCompanyUuid());
        startTime = System.currentTimeMillis();
        estatePhotoSync.pull(syncCommon, date);
        endTime = System.currentTimeMillis();
        log.info("run companyUuid {} estatePhotoSync end {} ", syncCommon.getCompanyUuid(), (endTime - startTime));

    }
}
